package logic

import (
	"context"
	"wxapi/internal/services"

	"wxapi/internal/svc"
	"wxapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetSymptomsListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetSymptomsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSymptomsListLogic {
	return &GetSymptomsListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetSymptomsListLogic) GetSymptomsList() (resp *types.GetSymtomsListResp, err error) {
	list, err := services.SymptomsList(l.ctx, l.svcCtx)
	if err != nil {
		return nil, err
	}

	resp = &types.GetSymtomsListResp{
		Symptoms: make([]types.Symptom, 0, len(list)),
	}
	for _, symptom := range list {
		resp.Symptoms = append(resp.Symptoms, types.Symptom{
			ID:     symptom.ID,
			Name:   symptom.SymptomName,
			Avatar: symptom.SymptomAvatar,
			Desc:   symptom.SymptomDesc,
		})
	}

	return
}
